# Contributor: Alexey Yerin <yyp@disroot.org>
# Maintainer: Alexey Yerin <yyp@disroot.org>
pkgname=fna3d
pkgver=24.11
pkgrel=0
_mojoshader_commit=1df57d1d9b6743735e5c3e509698a979d52ae58f
pkgdesc="3D Graphics Library for FNA"
url="http://fna-xna.github.io"
arch="all"
license="Zlib"
makedepends="cmake samurai sdl2-dev vulkan-headers"
subpackages="$pkgname-dev"
source="FNA3D-$pkgver.tar.gz::https://github.com/FNA-XNA/FNA3D/archive/$pkgver.tar.gz
	mojoshader-$_mojoshader_commit.tar.gz::https://github.com/icculus/mojoshader/archive/$_mojoshader_commit.tar.gz
	devendor-vulkan-headers.patch
	install.patch
	"
builddir="$srcdir/FNA3D-$pkgver"
options="!check" # No tests

prepare() {
	default_prepare

	rm -r "$builddir"/MojoShader "$builddir"/Vulkan-Headers
	cp -r "$srcdir"/mojoshader-$_mojoshader_commit "$builddir"/MojoShader
}

build() {
	if [ "$CBUILD" != "$CHOST" ]; then
		local crossopts="-DCMAKE_SYSTEM_NAME=Linux -DCMAKE_HOST_SYSTEM_NAME=Linux"
	fi
	cmake -B build -G Ninja \
		-DCMAKE_INSTALL_PREFIX=/usr \
		-DCMAKE_INSTALL_LIBDIR=lib \
		-DBUILD_SHARED_LIBS=ON \
		-DCMAKE_BUILD_TYPE=None \
		$crossopts
	cmake --build build
}

check() {
	ctest --test-dir build --output-on-failure
}

package() {
	DESTDIR="$pkgdir" cmake --install build
}

sha512sums="
b35e178d6a97254f1d8cad6802daf2eb94b7624ee87b0b97b91aa9a181915e2906c387d7082b4abf29752d5578e2e0667802906daed9c28110c9161187a76892  FNA3D-24.11.tar.gz
4a4b8d3120315ac884fd9ca85954504051035ebd75ea81d86a47ccf1454f272608a725c15c40d14c896eac7475cfb1cda0b85d9766b9cbc394204034989d2126  mojoshader-1df57d1d9b6743735e5c3e509698a979d52ae58f.tar.gz
ab8ed2c1608ee795681121eb6d14992d902eb14a41d06a90b846875f3e28e2ea75bb752e8328cca6c92df700b3735ab43bc308bf0ebeab1b833a83531c07dab1  devendor-vulkan-headers.patch
67f3e0c4e58898311db4756d421bb29be0a052484b948e2e1bc20cfeca1cc6e2acadb4eb346b16139e2da54e3b210957b2ef372f5387d56faf3fa0548e688d2b  install.patch
"
